package cn.yunhe.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/**
 * Created by Administrator on 2017/9/12.
 */
public class DButil {
    static final String DRIVER = "com.mysql.jdbc.Driver";
    static final String URL = "jdbc:mysql://localhost:3306/easy";
    static final String NAMNE = "root";
    static final String PASS = "000000";

    public static Connection getConn() {
        Connection conn = null;
        try {
            Class.forName(DRIVER);
            conn = DriverManager.getConnection(URL, NAMNE, PASS);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }


    public static void closeAll(Connection conn, Statement st, ResultSet rs){
        try{
            if (rs!=null){
                rs.close();
            }
            if (st!=null){
                st.close();
            }
            if (conn!=null){
                conn.close();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}
